<?php if($error == false) {?>

<table width="1028px" style="width:1028px">
	<tbody>
		<tr>
			<td width="100%">
				<table align="center" width="100%">
					<tbody>
						<tr>
							<td valign="top" style="text-align:left; vertical-align:top" width="30%">
								<b>TESRENG FEDERAL PAINT COMPANY</b><br>
								Tel: 012 855 424 - 097 97 37 222<br>
								Email: tesreng@gmail.com
							</td>
							<td valign="top" style="text-align:center; vertical-align:top" width="70%">
								<h2 style="padding:5px; margin-bottom:10px">INVENTORY BY BRANDS</h2>
								<div style="clear:both"></div>
								<div style="text-align:left">
									<table>
										<tr>
											<td style="text-align:center"><?php echo $this->document->text['text_date']?>: From <?php echo $search_fromdate?><?php echo $this->document->text['text_to']?><?php echo $search_todate?></td>
										</tr>
									</table>
								</div>
								<div style="clear:both"></div>
							</td>
						</tr>
					</tbody>
				</table>
				<?php foreach($reports as $brand) {?>
				<h3>Brand: <?php echo $brand["brandid"]?> - <?php echo $brand["brandname"]?></h3>
				<table class="grid" style="width:1028px" align="center" cellpadding="5" cellspacing="0">
					<thead style="font-weight:bold">
						 <tr class="tr-head">
							<th width="30px" rowspan="2">No.</th>
							<th width="180px" rowspan="2"><?php echo $this->document->text['text_groupname']?></th>
							<th width="180px" rowspan="2"><?php echo $this->document->text['text_barcode']?></th>
							<th width="210px" rowspan="2"><?php echo $this->document->text['text_productname']?></th>
							<th width="120px" rowspan="2"><?php echo $this->document->text['text_unit']?></th>
							<th width="120px" rowspan="2"><?php echo $this->document->text['text_startperiod']?></th>
							<th width="240px" colspan="2"><?php echo $this->document->text['text_inperiod']?></th>
							<th width="120px" rowspan="2"><?php echo $this->document->text['text_endperiod']?></th>
							<th width="100px" rowspan="2"><?php echo $this->document->text['text_importcost']?></th>
							<th width="100px" rowspan="2"><?php echo $this->document->text['text_totalcost']?> (<?php echo $this->document->text['text_instock']?>)</th>
						</tr>
						<tr class="tr-head">
							<th width="120px"><?php echo $this->document->text['text_import']?></th>
							<th width="120px"><?php echo $this->document->text['text_export']?></th>
						</tr>
					</thead>
					<tbody>
						<?php
							$index = 0;
							
							foreach($brand['items'] as $item)
							{
								
								$index += 1;
						?>
									<tr>
										<td><?php echo $index?></td>
									<td><?php echo $item['groupname']?></td>
									<td><?php echo $item['barcode']?></td>
									<td><?php echo $item['productname']?></td>
									<td><?php echo $item['unit']?></td>
									<td class="calc" style="text-align:right"><?php echo $item['sumstartperiod']?></td>
									<td class="calc" style="text-align:right"><?php echo $item['sumimportqty']?></td>
									<td class="calc" style="text-align:right"><?php echo $item['sumexportqty']?></td>
									<td class="calc" style="text-align:right"><?php echo $item['sumendperiod']?></td>
									<td class="calc" style="text-align:right"><?php echo $item['importcost']?></td>
									<td class="calc" style="text-align:right"><?php echo $item['totalcost']?></td>                    
									</tr>
						<?php
							}
						?>
					
					</tbody>
				</table>
				<?php } ?>
				<br>
				
				
			</td>
		</tr>
	</tbody>
	
</table>


<style>
body{font-family:Arial, Helvetica, sans-serif; font-size:10pt}
table{font-size:11pt}
table th{font-weight:bold; text-align:left}
.grid th, .grid td {font-size:10pt}
.grid td{ border:1px dotted #CCCCCC}
.grid th{ text-align:center; border:1px dotted #999999}
.sign td{width:25%; text-align:center; font-weight:bold}
</style>

<script src="<?php echo DIR_JS?>jquery.js" type="text/javascript"></script>
<script>
	$(document).ready(function(){
		$(".calc").each(function(){
			num = formateNumber($(this).html().replace(/,/g,""));
			$(this).html(num);
		});
		window.print();
	});
</script>

<?php } else  {?>
<h1>Occur Error!</h1>
<?php } ?>

